#ifndef WIIMOTE_CONNECTOR_H
#define WIIMOTE_CONNECTOR_H

#include "wiimote.h"
#include "Math.h"
#include "Point.h"
#include "Vector.h"

#define MAX_NUM_WIIMOTES 2

#define WIIMOTE_BUTTON_A 1

class WiimoteConnector
{
public:
	WiimoteConnector(void);
	~WiimoteConnector(void);

	void Update(void);
	Point3 GetEye(int wiimote);
	Point3 GetLookat(int wiimote);
	

	float GetPitch(int wiimote);
	float GetRoll(int wiimote);
	bool Connected(int wiimote);
	bool ButtonPressed(int wiimote, int button);
	bool SeesLED(int wiimote, int LED);

	void WiimoteConnector::UpdateIR(int wiimote,
		wiimote_state::ir::dot dot1, 
		wiimote_state::ir::dot dot2,
		wiimote_state::ir::dot dot3,
		wiimote_state::ir::dot dot4);
	int GetWiimoteNumber(wiimote& wiimote);

	static WiimoteConnector* singleton;
	wiimote* wiimotes;

protected:

private:
	void setup_connection(wiimote* wiimote_ptr, int wiimote_num);
	
	Point2 wiimotePointsNormalized[4];
	Point3* eye;
	Point3* lookat;
	
	bool* connected;
	float* pitch;
	float* old_pitch;
	float* roll;
	float* old_roll;
	float alpha;
};

void ir_change (wiimote &wiimote, state_change_flags changed);

#endif
